home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / srdisk12.zip / RDISK.ASM next >
Assembly Source File  |  1991-10-04  |  26KB  |  726 lines

  1. ;
  2. ;       ReSizeable RAMDisk device driver for XMS memory
  3. ;       Version 1.20
  4. ;
  5. ;       May be compiled with either MASM or TASM
  6. ;
  7. ;       Released to PUBLIC DOMAIN by author Marko Kohtala 1991
  8. ;
  9. ;       Some documentation available in accompanying file SRDISK.DOC.
  10. ;       If not, contact author by sending E-mail from
  11. ;
  12. ;               Internet, Bitnet etc. to 'mkohtala@niksula.hut.fi'
  13. ;               CompuServe to '>INTERNET:mkohtala@niksula.hut.fi'
  14. ;
  15. ;       or by calling Airline QBBS, 24H, HST, V.32, V.42, MNP,
  16. ;       +358-0-8725380, and leaving mail to me, Marko Kohtala.
  17. ;
  18. ; History:
  19. ; 1.00  Initial release
  20. ; 1.10  Added into IOCTL_msg media_change byte, that must be changed to
  21. ;       -1 by srdisk if media changed. Changed header version to SRD 1.10.
  22. ; 1.20  Fixed name of program by adding the missing 'Re' to 'Sizeable'.
  23. ;       Upgraded IOCTL_msg_s to version 1.20 by adding byte to tell usable
  24. ;       memory types.
  25. ;       Updated to work with DOS versions 2.x-5.x - not tested.
  26.  
  27. .286c
  28. d_seg           segment para public
  29.                 assume ds:d_seg, cs:d_seg
  30.  
  31.                 org     0
  32.                 ; Device driver header
  33.                 dd      -1              ; Pointer to next device (now last)
  34.                 dw      4800h           ; Support for IOCTL and removable media calls
  35.                 dw      offset strategy ; Offset to strategy function
  36.                 dw      offset commands ; Offset to commands function
  37.                 db      1               ; Number of units
  38.  
  39.                 ; Pointers to commands
  40. command_tbl     dw      cmd_init             ;  0
  41.                 dw      cmd_media            ;  1
  42.                 dw      cmd_BPB              ;  2
  43.                 dw      cmd_I_IOCTL          ;  3
  44.                 dw      cmd_input            ;  4
  45.                 dw      cmd_ok               ;  5
  46.                 dw      cmd_ok               ;  6
  47.                 dw      cmd_ok               ;  7
  48.                 dw      cmd_output           ;  8
  49.                 dw      cmd_output           ;  9 With verify
  50.                 dw      cmd_ok               ; 10
  51.                 dw      cmd_ok               ; 11
  52.                 dw      cmd_O_IOCTL          ; 12
  53.                 dw      cmd_open             ; 13
  54.                 dw      cmd_close            ; 14
  55.                 dw      cmd_removable        ; 15
  56.  
  57.  
  58. ;**************************************************************************
  59. ;
  60. ;                       IOCTL message structure
  61. ;
  62. ; This structure is the data packet exchanged between this device
  63. ; driver and the RAM disk formatter program. The formatter will first
  64. ; read this structure and verify the version of the message structure,
  65. ; then it will make any necessary modifications to it and send it back.
  66. ;
  67. ; !!! The formatter will use any initial values in this structure as
  68. ; default values i.e. set all needed values here !!!
  69. ;**************************************************************************
  70.  
  71. READ_ACCESS     equ     1       ; Bit masks for the RW_access
  72. WRITE_ACCESS    equ     2
  73.  
  74. XMS_MEMORY      equ     1       ; Different memory types supported bit masks
  75. EMS_MEMORY      equ     2
  76. CONV_MEMORY     equ     4
  77. BSW_MEMORY      equ     8
  78.  
  79. IOCTL_msg_s     struc
  80.                 dw      type IOCTL_msg_s ; Length of the structure
  81.                 db      90h             ; Makes this look like boot record
  82.                 db      'SRD 1.20'      ; IOCTL_msg structure version
  83.  
  84.                 ; BIOS Parameter Block structure
  85. bytes_per_sector dw     128             ; Smallest sector size
  86. sectors_per_cluster db  4               ; Cluster size 4*128 = 512
  87. reserved_sec    dw      1               ; The boot sector is reserved
  88. FATs            db      1               ; One FAT copy
  89. dir_entries     dw      64              ; 64 entries in root directory
  90. sectors         dw      ?               ; Total number of sectors on disk
  91. media           db      0FAh            ; Media is RAM DISK
  92. FAT_sectors     dw      ?               ; Sectors per one FAT
  93.                 ; Internal data
  94. disk_size       dw      0               ; Disk size in K-bytes (0 at start)
  95. volume          db      'SRDISK     ', 0 ; ASCIIZ string of volume label
  96. RW_access       db      00b             ; B0 = read, B1 = write (disabled now)
  97. media_change    db      1               ; -1 if media changed, 1 if not
  98.  
  99.                 ; These are not accepted from outside
  100. open_files      dw      0               ; Files currently open on drive
  101. IO_entry_off    dw      ?               ; External entry to disk_IO
  102. IO_entry_seg    dw      ?
  103. memory_type     db      XMS_MEMORY      ; This driver uses XMS memory
  104. IOCTL_msg_s     ends
  105.  
  106. O_IOCTL_msg_len equ     open_files      ; Number of bytes we accept from outside
  107.  
  108.                 ; Because of Bugs in TASM we must put 'type ...' here too
  109. IOCTL_msg       IOCTL_msg_s <type IOCTL_msg_s,,,,,,,,,,,,,,,,offset far_disk_IO>
  110.  
  111. ;**************************************************************************
  112. ;
  113. ;                       Local data
  114. ;
  115. ;**************************************************************************
  116.  
  117. BPB             equ     byte ptr IOCTL_msg.bytes_per_sector
  118. pBPB            dw      offset BPB      ; Pointer to BPB (for cmd_init)
  119.  
  120. req_ptr         dd      ?               ; Request structure pointer
  121.  
  122. XMS_entry       dd      ?               ; XMS driver entry point
  123. XMS_handle      dw      -1              ; XMS handle to disk memory
  124. XMS_cblk        db      16 dup (0)      ; XMS move command data structure
  125.  
  126.   
  127. ;**************************************************************************
  128. ;
  129. ;                       Set request header address
  130. ;
  131. ; Called by DOS to set the request structure pointer
  132. ;
  133. ;**************************************************************************
  134.   
  135. strategy        proc far
  136.                 mov     word ptr cs:req_ptr,bx
  137.                 mov     word ptr cs:req_ptr+2,es
  138.         retf                ; Return far
  139. strategy    endp
  140.   
  141.   
  142. ;**************************************************************************
  143. ;
  144. ;                       Commands
  145. ;
  146. ; Called by DOS. Requested action defined in structure pointed by req_ptr.
  147. ;
  148. ;**************************************************************************
  149.   
  150. commands        proc far
  151.         push    ax
  152.                 push    bx
  153.         push    cx
  154.         push    dx
  155.                 push    si
  156.         push    di
  157.         push    ds
  158.         push    es
  159.                 lds     si,cs:req_ptr
  160.                 ; We trust Microsoft that the unit is right at [req_ptr]+1
  161.                 mov     cx,[si+12h]             ; Sectors/Cmd line/BPB pointer
  162.                 mov     dx,[si+14h]             ; Start sector/Device number
  163.                 mov     bl,[si+2]               ; Command
  164.                 cmp     bl,0Fh                  ; Is command supported?
  165.                 ja      cmd_unknown             ; Jump if not
  166.                 xor     bh,bh                   ; Count index to command_tbl
  167.                 shl     bx,1
  168.                 les     di,dword ptr [si+0Eh]   ; ES:DI = transfer address
  169.         push    cs
  170.                 pop     ds                      ; DS to local data segment
  171.                 jmp     word ptr [command_tbl+bx] ; Do command
  172. cmd_unknown:
  173.                 mov     al,3
  174.                 jmp     cmd_error
  175. cmd_IOerr:
  176.                 lds     bx,cs:req_ptr
  177.                 mov     word ptr [bx+12h],0     ; Sector count zero
  178. cmd_error:
  179.                 mov     ah,81h                  ; ERROR and DONE
  180.                 jmp     cmd_ret
  181.  
  182. cmd_removable:  ; Enough to return DONE without BUSY flag set
  183. cmd_ok:
  184.                 mov     ah,1                    ; DONE
  185. cmd_ret:
  186.                 lds     bx,cs:req_ptr
  187.                 mov     [bx+3],ax               ; save status
  188.         pop    es
  189.         pop    ds
  190.         pop    di
  191.                 pop     si
  192.         pop    dx
  193.         pop    cx
  194.                 pop     bx
  195.         pop    ax
  196.         retf                ; Return far
  197. commands    endp
  198.  
  199.  
  200. ;**************************************************************************
  201. ;
  202. ;               Media Check command
  203. ;
  204. ;**************************************************************************
  205.  
  206. cmd_media       proc near
  207.                 les     bx,req_ptr
  208.  
  209.                 mov     ax,100h                 ; DONE status
  210.                 mov     dh,IOCTL_msg.media_change ; Read the change return
  211.  
  212.                 test    IOCTL_msg.RW_access,READ_ACCESS
  213.                 jnz     cmd_media1
  214.                 mov     ax,8102h                ; "Device not ready" status
  215.                 mov     dh,-1                   ; "Changed"
  216. cmd_media1:
  217.                 mov     es:[bx+0Eh],dh
  218.                 mov     word ptr es:[bx+0Fh],offset volume
  219.                 mov     es:[bx+11h],cs
  220.                 jmp     cmd_ret
  221. cmd_media       endp
  222.  
  223.  
  224. ;**************************************************************************
  225. ;
  226. ;               Build BPB command
  227. ;
  228. ;**************************************************************************
  229.  
  230. cmd_BPB         proc near
  231.                 les     bx,req_ptr
  232.                 mov     word ptr es:[bx+12h],offset BPB
  233.                 mov     es:[bx+14h],cs
  234.                 mov     IOCTL_msg.open_files,0  ; Reset open files to 0
  235.                 mov     IOCTL_msg.media_change,1 ; Media not changed
  236.                 test    IOCTL_msg.RW_access,READ_ACCESS
  237.                 jz      cmd_BPB1
  238.                 jmp     cmd_ok
  239. cmd_BPB1:
  240.                 mov     al,2                    ; "Device not ready"
  241.                 jmp     cmd_error
  242. cmd_BPB         endp
  243.  
  244.  
  245. ;**************************************************************************
  246. ;
  247. ;               Device Open command
  248. ;
  249. ;**************************************************************************
  250.  
  251. cmd_open        proc near
  252.                 inc     IOCTL_msg.open_files
  253.                 jmp     cmd_ok
  254. cmd_open        endp
  255.  
  256.  
  257. ;**************************************************************************
  258. ;
  259. ;               Device Close command
  260. ;
  261. ;**************************************************************************
  262.  
  263. cmd_close       proc near
  264.                 cmp     IOCTL_msg.open_files,0
  265.                 jz      cmd_close1
  266.                 dec     IOCTL_msg.open_files
  267. cmd_close1:
  268.                 jmp     cmd_ok
  269. cmd_close       endp
  270.  
  271.  
  272. ;**************************************************************************
  273. ;
  274. ;               INPUT command
  275. ;
  276. ;**************************************************************************
  277.  
  278. cmd_input       proc near
  279.                 test    IOCTL_msg.RW_access,READ_ACCESS
  280.                 jz      cmd_input1
  281.                 xor     bh,bh
  282.                 jmp     cmd_io
  283. cmd_input1:
  284.                 mov     al,2                    ; "Device not ready"
  285.                 jmp     cmd_IOerr
  286. cmd_input       endp
  287.  
  288.  
  289. ;**************************************************************************
  290. ;
  291. ;               OUTPUT command
  292. ;
  293. ;**************************************************************************
  294.  
  295. cmd_output      proc near
  296.                 test    IOCTL_msg.RW_access,WRITE_ACCESS
  297.                 jz      cmd_output1
  298.                 mov     bh,1
  299. cmd_io:
  300.                 call    disk_IO
  301.                 jc      cmd_output2             ; Jump if error
  302.                 jmp     cmd_ok
  303. cmd_output1:
  304.                 mov     al,0                    ; "Write protect violation"
  305. cmd_output2:
  306.                 jmp     cmd_IOerr
  307. cmd_output      endp
  308.   
  309.  
  310. ;**************************************************************************
  311. ;
  312. ;               I/O ROUTINE TO THE RAM DISK
  313. ;
  314. ; On entry
  315. ;   bh - 0 then read, else write
  316. ;   cx - number of sectors
  317. ;   dx - starting sector
  318. ;   es:di - transfer buffer
  319. ;
  320. ; Return
  321. ;   - carry clear if no error
  322. ;   - carry set and error code in al
  323. ;
  324. ;**************************************************************************
  325.  
  326. IO_err:
  327.                 mov     al,8                    ; "Sector not found"
  328.                 stc                             ; Set carry flag
  329.                 retn
  330.  
  331. disk_IO         proc near
  332.                 cmp     dx,IOCTL_msg.sectors    ; Startting sector on disk?
  333.                 jae     IO_err                  ; Jump if not
  334.                 mov     ax,dx                   ; Count ending sector
  335.         add    ax,cx
  336.                 cmp     ax,IOCTL_msg.sectors    ; Ending sector on disk?
  337.                 ja      IO_err                  ; Jump if not
  338.                 mov     si,offset XMS_cblk
  339.                 push    dx
  340.                 mov     ax,cx                   ; Count number of words to move
  341.                 mul     IOCTL_msg.bytes_per_sector
  342.                 jnc     disk_IO1                ; Jump if not too much
  343.  
  344.                 push    ds                      ; -- Make moved block shorter
  345.                 push    bx                      ;  and count the sectors
  346.                 mov     ax,0F000h               ; 0F000h should divide with
  347.                 push    ax
  348.                 div     IOCTL_msg.bytes_per_sector ; every bytes_per_sector
  349.                 lds     bx,req_ptr
  350.                 mov     [bx+12h],ax             ; Report right sector count
  351.                 pop     ax
  352.                 pop     bx
  353.                 pop     ds
  354. disk_IO1:
  355.                 mov     [si],ax                 ; Number of bytes to move
  356.                 mov     word ptr [si+2],0
  357.  
  358.                 pop     ax                      ; Pushed as dx, start sector
  359.                 mul     IOCTL_msg.bytes_per_sector ; dx:ax = the starting byte
  360.   
  361.                 or      bh,bh                   ; Input/output?
  362.                 mov     bx,XMS_handle
  363.                 jnz     disk_IO2                ; Jump if write
  364.                                                 ; -- Read
  365.                 mov     [si+4],bx               ; Source in XMS
  366.                 mov     [si+6],ax
  367.                 mov     [si+8],dx
  368.                 mov     word ptr [si+0Ah],0     ; Destination in main memory
  369.                 mov     [si+0Ch],di
  370.                 mov     [si+0Eh],es
  371.                 jmp     disk_IO3
  372. disk_IO2:                                       ; -- Write
  373.                 mov     word ptr [si+4],0       ; Source in main memory
  374.                 mov     [si+6],di
  375.                 mov     [si+8],es
  376.                 mov     [si+0Ah],bx             ; Destination in XMS
  377.                 mov     [si+0Ch],ax
  378.                 mov     [si+0Eh],dx
  379. disk_IO3:
  380.                 mov     ah,0Bh                  ; Move XMS block
  381.                 call    XMS_entry
  382.                 shr     ax,1
  383.                 cmc                             ; Carry set if err
  384.                 jnc     disk_IO_ret
  385.                 mov     al,0Ch                  ; "General failure"
  386. disk_IO_ret:
  387.                 ret
  388. disk_IO         endp
  389.  
  390.   
  391. ;**************************************************************************
  392. ;
  393. ;               EXTERNAL I/O ROUTINE TO THE RAM DISK
  394. ;
  395. ; On entry
  396. ;   bh - 0 then read, else write
  397. ;   cx - number of sectors
  398. ;   dx - starting sector
  399. ;   es:di - transfer buffer
  400. ;
  401. ; Return in ax: 0 for success, 1 for failure
  402. ;
  403. ;**************************************************************************
  404.   
  405. far_disk_IO     proc far
  406.                 push    ds
  407.                 push    si
  408.                 push    di
  409.                 push    cs                      ; Switch to local data segment
  410.                 pop     ds
  411.                 call    disk_IO
  412.                 xor     ax,ax
  413.                 jnc     far_disk_IO1
  414.                 inc     ax
  415. far_disk_IO1:
  416.                 pop     di
  417.                 pop     si
  418.                 pop     ds
  419.                 ret
  420. far_disk_IO     endp
  421.  
  422.  
  423. ;**************************************************************************
  424. ;
  425. ;                      IOCTL Read - send configuration
  426. ;
  427. ;**************************************************************************
  428.  
  429. cmd_I_IOCTL     proc near
  430.                 cmp     cx,type IOCTL_msg_s     ; Requested too much?
  431.                 jna     cmd_I1
  432.  
  433.                 mov     cx,type IOCTL_msg_s     ; Yes, send less than asked
  434.                 push    ds
  435.                 lds     bx,req_ptr
  436.                 mov     [bx+12h],cx
  437.                 pop     ds
  438. cmd_I1:
  439.                 mov     si,offset IOCTL_msg
  440.                 rep     movsb
  441.                 jmp     cmd_ok
  442. cmd_I_IOCTL     endp
  443.  
  444.  
  445. ;**************************************************************************
  446. ;
  447. ;                      IOCTL Write - receive new configuration
  448. ;
  449. ;**************************************************************************
  450.  
  451. cmd_O_IOCTL     proc near
  452.                 cmp     cx,type IOCTL_msg_s     ; Validate the length
  453.                 jne     cmd_O_abort
  454.  
  455.                 push    di                      ; Validate the header
  456.                 mov     si,offset IOCTL_msg
  457.                 mov     cx,11
  458.                 repe    cmpsb
  459.                 pop     si
  460.                 jne     cmd_O_abort
  461.  
  462.                 cmp     es:[si].media_change,1  ; See if no media change
  463.                 je      cmd_O1                  ; If not, no change in the disk
  464.  
  465.                 mov     IOCTL_msg.open_files,0  ; No open files, if media change
  466.                 mov     bx,es:[si].disk_size    ; See if disk size change
  467.                 cmp     bx,IOCTL_msg.disk_size
  468.                 je      cmd_O1
  469.  
  470.                 mov     dx,XMS_handle           ; Change XMS disk size
  471.                 mov     ah,0Fh
  472.                 call    XMS_entry
  473.                 or      ax,ax
  474.                 jz      cmd_O_fail              ; Report that failed
  475. cmd_O1:
  476.                 mov     di,offset IOCTL_msg     ; Read it
  477.                 mov     cx,O_IOCTL_msg_len      ; Exclude the tail
  478.                 push    ds                      ; Swap es<->ds
  479.                 push    es
  480.                 pop     ds
  481.                 pop     es
  482.                 rep     movsb                   ; Write the internal table
  483.                 jmp     cmd_ok
  484.  
  485. cmd_O_abort:    mov     al,0Ah                  ; "Write fault"
  486.                 jmp     cmd_IOerr
  487.  
  488. cmd_O_fail:     mov     al,0Ch                  ; "General failure"
  489.                 jmp     cmd_IOerr
  490.  
  491. cmd_O_IOCTL     endp
  492.  
  493.  
  494. ;**************************************************************************
  495. ;
  496. ;                       Warm Boot of Machine
  497. ;
  498. ; Release used XMS memory.
  499. ;
  500. ; I guess this may be important if some virtual machine (VM) in some
  501. ; multitasking system has installed this driver and the VM is ended.
  502. ; Without this the other VMs would loose the space reserved for RAM disk
  503. ; in this VM.
  504. ;**************************************************************************
  505.   
  506. old_int19       label dword                     ; Address of old INT 19
  507. old_int19_off   dw      -1
  508. old_int19_seg   dw      -1
  509.  
  510. int_19_entry    proc far
  511.                 pusha
  512.                 mov     dx,cs:XMS_handle
  513.                 cmp     dx,-1
  514.                 je      int19_1                 ; Jump if no XMS handle
  515.         mov    ah,0Dh
  516.                 call    cs:XMS_entry            ; Unlock XMS memory
  517.         mov    ah,0Ah
  518.                 call    cs:XMS_entry            ; Free XMS memory
  519. int19_1:
  520.                 xor     ax,ax
  521.         mov    ds,ax
  522.                 mov     ax,cs:old_int19_off
  523.         cli                ; Disable interrupts
  524.                 mov     ds:[19h*4],ax           ; for the time to write
  525.                 mov     ax,cs:old_int19_seg     ; old interrupt vector back
  526.                 mov     ds:[19h*4+2],ax
  527.                 popa                            ; Enable interrupts
  528.                 jmp     cs:old_int19
  529. int_19_entry    endp
  530.   
  531.  
  532. end_of_resident label byte      ; MARKS THE END OF RESIDENT PORTION OF DRIVER
  533.  
  534.  
  535. ;**************************************************************************
  536. ;
  537. ;                       prints macro
  538. ;
  539. ; This macro is used by initialization routines to display text.
  540. ; dx must point to the '$' terminated text about to be displayed.
  541. ;**************************************************************************
  542.   
  543. prints        macro
  544.         mov    ah,9
  545.                 int     21h
  546.               endm
  547.   
  548.   
  549. ;**************************************************************************
  550. ;
  551. ;                       INIT command
  552. ;
  553. ; Init command does the following:
  554. ;  - checks DOS version. This driver is built in a way that requires
  555. ;    at least dos version 3.00. I'm not sure wether even that is enough.
  556. ;  - displays sign-on message (must display it after DOS version check
  557. ;    because older versions do not report the drive)
  558. ;  - initialize XMS to 0K disk
  559. ;  - hook INT 19 bootstrap interrupt
  560. ;  - fills in the request header
  561. ;**************************************************************************
  562.   
  563. cmd_init        proc near
  564.                 mov     ah,30h
  565.                 int     21h                     ; Get DOS version number
  566.  
  567.         xchg    ah,al
  568.                 cmp     ax,200h
  569.                 jb      cmd_init1
  570.         cmp    ax,600h
  571.                 jb      cmd_init2
  572. cmd_init1:
  573.                 mov     dx,offset errs_eDOS
  574.                 jmp     cmd_init_err
  575. cmd_init2:
  576.                 les     si,req_ptr
  577.                 cmp     byte ptr es:[si],16h    ; Device number supported?
  578.                 ja      cmd_init4               ; Yes, use it
  579.  
  580.                 mov     s_vdisk,'$'             ; Do not display "Virtual disk"
  581.                 jmp     cmd_init5
  582. cmd_init4:
  583.                 mov     al,es:[si+16h]          ; Get drive number
  584.                 add     s_drive,al              ; and insert it to the string
  585.  
  586. cmd_init5:      mov     dx,offset s_sign_on     ; "Microsoft RAMdrive ver..."
  587.                 prints
  588.  
  589.                 call    init_XMS
  590.                 jc      cmd_init_abort
  591.  
  592.                 call    set_int19
  593.   
  594.                 mov     IOCTL_msg.IO_entry_seg,cs
  595.  
  596.                 mov     al,1                    ; One drive installed
  597.                 lds     bx,req_ptr
  598.                 mov     [bx+0Dh],al             ; Save number of drives
  599.                 mov     word ptr [bx+0Eh],offset end_of_resident
  600. cmd_init3:
  601.                 mov     [bx+10h],cs
  602.                 mov     word ptr [bx+12h],offset pBPB
  603.                 mov     [bx+14h],cs
  604.                 jmp     cmd_ok
  605.  
  606. cmd_init_err:
  607.                 prints
  608. cmd_init_abort:
  609.                 lds     bx,req_ptr
  610.                 xor     ax,ax
  611.                 mov     [bx+0Dh],al             ; Zero the number of drives
  612.                 mov     [bx+0Eh],ax
  613.                 jmp     cmd_init3
  614.  
  615. cmd_init        endp
  616.   
  617.   
  618. ;**************************************************************************
  619. ;
  620. ;                       INT 19 hooking
  621. ;
  622. ; INT 19 is the bootstrap loader interrupt, which is invoked when user
  623. ; presses Ctrl-Alt-Del. We must hook it in order to release the
  624. ; extended memory allocated for RAM disk.
  625. ;**************************************************************************
  626.   
  627. set_int19       proc near
  628.         push    ax
  629.         push    dx
  630.         push    bx
  631.         push    es
  632.         mov    ax,3519h
  633.                 int     21h                     ; Get old int 19 handler
  634.                 mov     old_int19_off,bx
  635.                 mov     old_int19_seg,es
  636.                 mov     dx,offset int_19_entry
  637.         mov    ax,2519h
  638.                 int     21h                     ; Set new int 19 handler
  639.  
  640.         pop    es
  641.         pop    bx
  642.         pop    dx
  643.         pop    ax
  644.         retn
  645. set_int19       endp
  646.   
  647.   
  648. ;**************************************************************************
  649. ;
  650. ;                       XMS memory initialization
  651. ;
  652. ; Gets XMS server entry address and allocates 0K to get a memory handle
  653. ; for RAM disk
  654. ;
  655. ; Returns
  656. ;   carry set if error
  657. ;**************************************************************************
  658.   
  659. init_XMS        proc near
  660.                 push    es
  661.                 mov     ax,4300h
  662.                 int     2Fh                     ; Get XMS installed status
  663.         cmp    al,80h
  664.                 jne     init_XMS1               ; Jump if not installed
  665.                 mov     ax,4310h
  666.                 int     2Fh                     ; Get XMS entry point
  667.                 jnc     init_XMS2               ; Jump if no error
  668. init_XMS1:
  669.                 mov     dx,offset errs_noXMS    ; "No extended mem driver"
  670.                 jmp     init_XMS4
  671. init_XMS2:
  672.                 mov     word ptr XMS_entry,bx
  673.                 mov     word ptr XMS_entry+2,es
  674.                 xor     dx,dx                   ; Allocate 0K to get a handle
  675.                 mov     ah,9
  676.                 call    XMS_entry
  677.                 or      ax,ax
  678.                 jz      init_XMS3               ; Zero for failure
  679.                 mov     XMS_handle,dx
  680.                 clc
  681.                 jmp     init_XMS_ret
  682. init_XMS3:
  683.                 mov     dx,offset errs_ealloc   ; "Error in ext mem alloc"
  684. init_XMS4:
  685.                 prints
  686.                 stc
  687. init_XMS_ret:
  688.                 pop     es
  689.                 ret
  690. init_XMS        endp
  691.  
  692.  
  693. ;**************************************************************************
  694. ;
  695. ;                       Initialization strings
  696. ;
  697. ;**************************************************************************
  698.  
  699. errs_noXMS      db      'RAMDisk: Extended Memory Manager not present'
  700.                 db      0Dh, 0Ah, '$'
  701. errs_ealloc     db      'RAMDisk: Error in extended memory allocation'
  702.                 db      0Dh, 0Ah, '$'
  703. errs_eDOS       db      'RAMDisk: Incorrect DOS version'
  704.                 db      0Dh, 0Ah, '$'
  705. s_sign_on       db      0Dh, 0Ah, 'ReSizeable RAMDisk (XMS) version 1.20, '
  706.                 db      'PUBLIC DOMAIN, 1991'
  707.                 db      0Dh, 0Ah
  708. s_vdisk         db      'Virtual disk '
  709. s_drive         db      'A:', 0Dh, 0Ah
  710.                 db      0Dh, 0Ah, '$'
  711.   
  712.  
  713. ;**************************************************************************
  714. ;
  715. ;                       A note for binary debuggers
  716. ;
  717. ;**************************************************************************
  718.  
  719. db "Released to PUBLIC DOMAIN by author Marko Kohtala 1991. "
  720. db "Contact from Internet, Bitnet etc. to 'mkohtala@niksula.hut.fi', "
  721. db "CompuServe to '>INTERNET:mkohtala@niksula.hut.fi'"
  722.  
  723.  
  724. d_seg           ends
  725.                 end
  726.